@extends('admin.layout.app')

@section('title')
    系统配置
@endsection

@section('style')
	<link rel="stylesheet" type="text/css" href="/admin/css/update_pass.css">
@endsection

@section('content') 
	@component('admin.components.nav') 
	@endcomponent
		<!--main-->
		<main>
			<div id="update-container" class="container">
				<div class="breadcrumb">
					<div class="row">
						<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
							<h3>系统配置</h3>
						</div>
					</div>
				</div>
				<div class="update-wrap">
					<div class="row">
						<div class="col-xs-12 col-sm-10 col-sm-offset-1">
							<form action="" id="update-form">
								<div class="form-group has-feedback">
								    <label class="control-label" for="">处长评分得分比例</label>
								    <input type="number" class="form-control" id="" placeholder="">
								</div>
								<div class="form-group has-feedback">
								    <label class="control-label" for="">副处长评分得分比例</label>
								    <input type="number" class="form-control" id="" placeholder="">
									<p class="help-block text-danger" :class="{invisible:!hasError}">得分比例相加必须为100！</p>
								</div>
								<div class="form-group text-center">
									<button type="button" class="btn btn-primary btn-update"  data-loading-text="正在提交"  @click="updatePass">确认修改</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</main>
@endsection

@section('script')
	<script type="text/javascript">
        var activeIndex = 6
    </script>
    <script src="/admin/js/nav.js" type="text/javascript"></script>
		<script type="text/javascript">
			$('#modal-form').modal({
				show: false
			})
			
			var update_vm = new Vue({
				el:'#update-container',
				data:{
					formData:{
						value:[30,40,20,10]
					},
					hasError:false,
					show_old:false,
					show_new:false,
					show_confirm:false
				},
				methods:{
					toggleInput(index){
						switch(index)
						{
							case 0:
								this.show_old = !this.show_old;
								break;
							case 1:
								this.show_new = !this.show_new;
								break;
							case 2:
								this.show_confirm = !this.show_confirm;
								break;
							default:
								break;
						}
					},
					updatePass(){
						var target = event.currentTarget
						$(target).button('loading');
						var self = this
						axios.put(window.config.host+'/user/reset_password',this.formData,{
							headers:{
	                            Authorization: 'Bearer '+this.token
	                        }
						})
						.then(function(res){
							if(res.status == 200){
								alert('更改密码成功，请重新登录')
								localStorage.userinfo = null
								localStorage.token = null
								Cookies.set('userinfo',null)
								Cookies.set('token',null)
								// window.location.href = '/'
							}else{
								alert(res.data.message)
							}
						})
						.catch(function(err){

						})
						.then(function(){
							$(target).button('reset');
						})
					}
				}
			})
		</script>
@endsection